﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Xml;
using System.Data;

using BLL;
using DAL;
using Models;


public partial class cn_UserControl_home_slides : System.Web.UI.UserControl
{
    // Fields
    protected ArticleManager am = new ArticleManager();
    protected ArticleTypeManager atm = new ArticleTypeManager();
    protected string xmlPath = "/cn/xml/home.xml";

    // Methods
    protected StringBuilder HomeSlidesBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            XmlElement element;
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.xmlPath));
            XmlNodeList childNodes = document.SelectSingleNode("home_ad/slides").ChildNodes;
            builder.AppendLine("<div class=\"banner_show\">");
            builder.AppendLine("<div class=\"slides\">");
            builder.AppendLine("<ul class=\"slide-pic\">");
            int num = 0;
            foreach (XmlNode node in childNodes)
            {
                element = (XmlElement)node;
                builder.AppendLine("<li " + ((num == 0) ? "class=\"cur\"" : "") + " >");
                builder.AppendLine("<a href=\"" + element.GetAttribute("url") + "\" target=\"_blank\"><img src=\"" + element.GetAttribute("src") + "\" alt=\"" + element.GetAttribute("alt") + "\" /></a>");
                builder.AppendLine("</li>");
                num++;
            }
            builder.AppendLine("</ul>");
            builder.AppendLine("<ul class=\"slide-li slide-txt op\">");
            num = 0;
            foreach (XmlNode node in childNodes)
            {
                element = (XmlElement)node;
                builder.AppendLine("<li " + ((num == 4) ? "class=\"last\"" : "") + "><a href=\"" + element.GetAttribute("url") + "\" target=\"_blank\">" + element.GetAttribute("alt") + "</a></li>");
            }
            builder.AppendLine("</ul>");
            builder.AppendLine("</div>");
            XmlElement element2 = (XmlElement)document.SelectSingleNode("home_ad/slides_bottom");
            builder.AppendLine("<div class=\"banner_img\">");
            builder.AppendLine("<a href=\"" + element2.GetAttribute("url") + "\" target=\"_blank\"><img src=\"" + element2.GetAttribute("src") + "\" alt=\"" + element2.GetAttribute("alt") + "\" /></a>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"news_info\">");
            builder.AppendLine("<div class=\"content-box\">");
            builder.AppendLine("<div class=\"content-box-header\">");
            builder.AppendLine("<ul class=\"content-box-tabs\">");
            builder.AppendLine("<li><a href=\"#tab1\" class=\"default-tab\">资讯中心</a></li>");
            builder.AppendLine("<li><a href=\"#tab2\">积分回馈</a></li>");
            builder.AppendLine("</ul>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"content-box-content\">");
            builder.AppendLine("<div class=\"tab-content default-tab\" id=\"tab1\">");
            builder.AppendLine("<ul>");
            DataTable atricleByArticleTypeIdAndTop = this.am.GetAtricleByArticleTypeIdAndTop(this.atm.GetIdByTypeNameAndParentIdAndLanguageVersionAndIsShow("资讯中心", "00000000-0000-0000-0000-000000000000", "zh-CN", 1), 4);
            foreach (DataRow row in atricleByArticleTypeIdAndTop.Rows)
            {
                builder.AppendLine(string.Concat(new object[] { "<li><a href=\"/cn/news_center/news_detail.html?id=", row["id"], "\" title=\"", row["articleTilte"], "\">- ", (row["articleTilte"].ToString().Length > 15) ? (row["articleTilte"].ToString().Substring(0, 15) + "...") : row["articleTilte"], "</a></li>" }));
            }
            builder.AppendLine("</ul>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"tab-content\" id=\"tab2\">");
            builder.AppendLine("<ul>");
            DataTable table2 = this.am.GetAtricleByArticleTypeIdAndTop(this.atm.GetIdByTypeNameAndParentIdAndLanguageVersionAndIsShow("积分回馈", "00000000-0000-0000-0000-000000000000", "zh-CN", 1), 4);
            foreach (DataRow row in table2.Rows)
            {
                builder.AppendLine(string.Concat(new object[] { "<li><a href=\"#\" title=\"", row["articleTilte"], "\">- ", (row["articleTilte"].ToString().Length > 15) ? (row["articleTilte"].ToString().Substring(0, 15) + "...") : row["articleTilte"], "</a></li>" }));
            }
            builder.AppendLine("</ul>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"img_link\">");
            XmlNodeList list2 = document.SelectSingleNode("home_ad/slides_right").ChildNodes;
            foreach (XmlNode node in list2)
            {
                element = (XmlElement)node;
                builder.AppendLine("<a href=\"" + element.GetAttribute("url") + "\" target=\"_blank\"><img src=\"" + element.GetAttribute("src") + "\" alt=\"" + element.GetAttribute("alt") + "\" /></a>");
            }
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

}